<div class="xn_c_content">
  <div class="xf_ht_tablelist">
    <!-- 搜索 -->
    #{form @safeQuestion(), id:'submit'}
    <div class="xf_ht_search_inon">
    <div class="xf_ht_search_r">
      <div class="xf_ht_search_xl">
      <input type="text" class="search_w" name="name" id="textfield" placeholder="安全问题" value="${page.conditions.name}" style="width:150px">
      </div>
      <div class="xf_ht_search_xl">
      <input type="button" class="search_button" onClick="submit()"" value="搜索">
      </div>
    </div>
    </div>
    #{/form}
    <!-- 列表内容 -->
    <div class="xn_c_content_top">
    #{table class:"xn_c_content_list", cellspacing:"0", cellpadding:"0", border:"0", tr_class_odd:"xn_tr_bj"}
    #{tr}
      #{th}序号#{/th}
      #{th}安全问题#{/th}
      #{th}答案数据格式#{/th}
      #{th}使用次数#{/th}
      #{th}状态#{/th}
      #{th}操作#{/th}
    #{/tr}
    #{list items:page?.page, as:'safeQuestion'}        
    #{tr tr_index:_index}
      #{td}${(page?.currPage - 1)*page?.pageSize + safeQuestion_index}#{/td}
      #{td}${safeQuestion?.name}#{/td}
      #{td}${safeQuestion?.type}#{/td}
      #{td}${safeQuestion?.useCount}#{/td}
      #{td}
      #{if safeQuestion.isUse}
                        正常
      #{/if}
      #{else}
                        暂停
      #{/else}
      #{/td}
      #{td}
      #{if safeQuestion.isUse}
      <span><a onClick="updateSafeQuestion('${safeQuestion?.id}','true')" class="xf_ta_onclick">暂停</a></span>
      #{/if}
      #{else}
      <span><a onClick="updateSafeQuestion('${safeQuestion?.id}','false')" class="xf_ta_onclick">启用</a></span>
      #{/else}
      #{/td}
    #{/tr}
    #{/list}
    #{/table}
    </div>
    <!-- 列表底部 -->
    <div class="xn_c_content_bottom">
      #{page currPage:page.currPage,totalCount:page.totalCount,pageSize:page.pageSize,theme:1,style:4}#{/page}
      <input type="button" onClick="addQuestion()" value="添加新问题" class="xf_ggnr_help_input"/>
    </div>
  </div>
</div>
<script>
  function addQuestion(){
    $.layer({
      type: 1,
      area: ['400', '180'],
      title: '添加安全问题',
      page: {dom : "#xf_ht_glylist_ttc"}
    });
      //showDiv($("#xf_ht_glylist_ttc"));
  }

  function submit(){
       $("#submit").submit();
  }
  
  function updateSafeQuestion(id,status){
       var updateSafeQuestion = #{jsAction @updateSafeQuestion(':id',':status')/}
     $.post(updateSafeQuestion({id:id,status:status}),function(data){
     var arr=eval(data);
     
     if(arr.error.code < 0){
             alert(arr.error.msg);
             return;
         }
         alert(arr.error.msg);
          location.reload();
         });
  }
</script>
